package com.edu.test;

import com.edu.bean.Book;
import com.edu.bean.BookExample;
import com.edu.mapper.BookMapper;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/*
 * @Author:mx
 * @Date:2025/10/15-9:01:17
 */
public class MyTest02 {

    private SqlSession session1 ;


    @Before
    public void init() throws IOException {
        String path = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(path);
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        session1 = sessionFactory.openSession();

    }

    @Test
    public void test01(){
        BookMapper bookMapper = session1.getMapper(BookMapper.class);
        BookExample bookExample = new BookExample();//查询模板
        bookExample.createCriteria().andBookTypeEqualTo("文学");
        bookExample.setOrderByClause("bookPrice desc");
        PageHelper.startPage(1,5);
        System.out.println(bookMapper.selectByExample(bookExample));
    }


    @Test
    public void test03(){
        int num = 39276;
        System.out.println((char)num);
        System.out.println('翔'+0);
    }

}
